import 'package:exsun_plate_app/mvp/model/get_code_entity.dart';
import 'package:exsun_plate_app/mvp/repository/get_code_repository.dart';
import 'package:dio/dio.dart';
import 'package:exsun_plate_app/common/api.dart';

class GetCodeRepositoryIml implements GetCodeRepository{
  @override
  Future<GetCodeEntity> fetch(String phone) {
    return _getCode(phone);
  }

  Future<GetCodeEntity> _getCode(String phone)  async {
    var loginURL = APIS.DEVELOP_URL+APIS.GET_CODE;
    Response response;
    //表单提交
    FormData formData = new FormData.from({
      "phone": phone,
    });
    Dio dio = new Dio();
    try {
      response = await dio.post(loginURL,data: formData);
      var data = response.data;
      print(data);
      return GetCodeEntity.fromJson(data);
    } catch (e, s) {
      print(s);
      return null;
    }
  }

}